/*
 * DesktopApplication1View.java
 */
package desktopapplication1;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import users.Users;

/**
 * The application's main frame.
 */
public class CDView extends FrameView {

    SingleFrameApplication app;

    public CDView(SingleFrameApplication app, List<String> Titles) {
        super(app);
        this.app = app;
        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
        titlelist.setListData(Titles.toArray());


        if (Users.loggedin()) {
            out6.setVisible(false);
            out1.setVisible(false);
            password1.setVisible(false);
            out3.setVisible(false);
            password1.setVisible(false);
            in1.setVisible(true);
            in2.setVisible(true);
            in3.setVisible(true);
            in2.setText(Users.getCurrentUser().getUsername());
            in4.setVisible(true);
            wishlist.setVisible(true);

            out1.setText("Username");
            password1.setText("Password");
        } else {

            out1.setVisible(true);
            password1.setVisible(true);
            out3.setVisible(true);
            password1.setVisible(true);
            out6.setVisible(true);
            in1.setVisible(false);
            in2.setVisible(false);
            in3.setVisible(false);
            in4.setVisible(false);
            out1.setText("Username");
            password1.setText("Password");
            wishlist.setVisible(false);

        }

    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = DesktopApplication1.getApplication().getMainFrame();
            aboutBox = new DesktopApplication1AboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        DesktopApplication1.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jInternalFrame1 = new javax.swing.JInternalFrame();
        jLabel1 = new javax.swing.JLabel();
        jButton6 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        titlelist = new javax.swing.JList();
        in4 = new javax.swing.JPanel();
        in3 = new javax.swing.JButton();
        in1 = new javax.swing.JLabel();
        in2 = new javax.swing.JLabel();
        wishlist = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        home1 = new javax.swing.JButton();
        browse1 = new javax.swing.JButton();
        back1 = new javax.swing.JButton();
        out6 = new javax.swing.JPanel();
        out1 = new javax.swing.JTextField();
        password1 = new javax.swing.JTextField();
        loginbutton1 = new javax.swing.JButton();
        out3 = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        jFrame1 = new javax.swing.JFrame();
        jFrame2 = new javax.swing.JFrame();
        jFrame3 = new javax.swing.JFrame();

        mainPanel.setName("mainPanel"); // NOI18N

        jInternalFrame1.setName("jInternalFrame1"); // NOI18N
        jInternalFrame1.setPreferredSize(new java.awt.Dimension(1045, 641));
        jInternalFrame1.setVisible(true);
        jInternalFrame1.getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopapplication1.DesktopApplication1.class).getContext().getResourceMap(CDView.class);
        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        jInternalFrame1.getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 150, -1, -1));

        jButton6.setText(resourceMap.getString("jButton6.text")); // NOI18N
        jButton6.setName("jButton6"); // NOI18N
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jInternalFrame1.getContentPane().add(jButton6, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 390, 135, -1));

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        titlelist.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        titlelist.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        titlelist.setName("titlelist"); // NOI18N
        jScrollPane1.setViewportView(titlelist);

        jInternalFrame1.getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 180, 439, 189));

        in4.setName("in4"); // NOI18N

        in3.setText(resourceMap.getString("in3.text")); // NOI18N
        in3.setName("in3"); // NOI18N
        in3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                in3ActionPerformed(evt);
            }
        });

        in1.setText(resourceMap.getString("in1.text")); // NOI18N
        in1.setName("in1"); // NOI18N

        in2.setText(resourceMap.getString("in2.text")); // NOI18N
        in2.setName("in2"); // NOI18N

        org.jdesktop.layout.GroupLayout in4Layout = new org.jdesktop.layout.GroupLayout(in4);
        in4.setLayout(in4Layout);
        in4Layout.setHorizontalGroup(
            in4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(in4Layout.createSequentialGroup()
                .add(in4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(in4Layout.createSequentialGroup()
                        .add(5, 5, 5)
                        .add(in1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(in2))
                    .add(in4Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(in3)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        in4Layout.setVerticalGroup(
            in4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(in4Layout.createSequentialGroup()
                .add(in4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(in2)
                    .add(in1))
                .add(18, 18, 18)
                .add(in3)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jInternalFrame1.getContentPane().add(in4, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 130, 60));

        wishlist.setText(resourceMap.getString("wishlist.text")); // NOI18N
        wishlist.setName("wishlist"); // NOI18N
        wishlist.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wishlistActionPerformed(evt);
            }
        });
        jInternalFrame1.getContentPane().add(wishlist, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 110, -1, -1));

        jLabel5.setFont(resourceMap.getFont("jLabel5.font")); // NOI18N
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N
        jInternalFrame1.getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 0, -1, -1));

        home1.setText(resourceMap.getString("home1.text")); // NOI18N
        home1.setName("home1"); // NOI18N
        jInternalFrame1.getContentPane().add(home1, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 20, -1, -1));

        browse1.setText(resourceMap.getString("browse1.text")); // NOI18N
        browse1.setName("browse1"); // NOI18N
        jInternalFrame1.getContentPane().add(browse1, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 50, -1, -1));

        back1.setText(resourceMap.getString("back1.text")); // NOI18N
        back1.setName("back1"); // NOI18N
        jInternalFrame1.getContentPane().add(back1, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 80, -1, -1));

        out6.setName("out6"); // NOI18N

        out1.setText(resourceMap.getString("out1.text")); // NOI18N
        out1.setName("out1"); // NOI18N
        out1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                out1FocusGained(evt);
            }
        });

        password1.setText(resourceMap.getString("password1.text")); // NOI18N
        password1.setName("password1"); // NOI18N
        password1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                password1FocusGained(evt);
            }
        });

        loginbutton1.setText(resourceMap.getString("loginbutton1.text")); // NOI18N
        loginbutton1.setName("loginbutton1"); // NOI18N
        loginbutton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loginbutton1ActionPerformed(evt);
            }
        });

        out3.setText(resourceMap.getString("out3.text")); // NOI18N
        out3.setName("out3"); // NOI18N
        out3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                out3ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout out6Layout = new org.jdesktop.layout.GroupLayout(out6);
        out6.setLayout(out6Layout);
        out6Layout.setHorizontalGroup(
            out6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(out6Layout.createSequentialGroup()
                .add(out1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(out3))
            .add(password1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .add(out6Layout.createSequentialGroup()
                .add(21, 21, 21)
                .add(loginbutton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
        out6Layout.setVerticalGroup(
            out6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(out6Layout.createSequentialGroup()
                .add(out6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(out1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(out3))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(password1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(loginbutton1)
                .addContainerGap())
        );

        jInternalFrame1.getContentPane().add(out6, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, 118));

        org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(jInternalFrame1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 592, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(659, Short.MAX_VALUE))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup()
                .add(23, 23, 23)
                .add(jInternalFrame1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 560, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(149, Short.MAX_VALUE))
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(desktopapplication1.DesktopApplication1.class).getContext().getActionMap(CDView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        org.jdesktop.layout.GroupLayout statusPanelLayout = new org.jdesktop.layout.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1271, Short.MAX_VALUE)
            .add(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(statusMessageLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 1075, Short.MAX_VALUE)
                .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(statusPanelLayout.createSequentialGroup()
                .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(statusMessageLabel)
                    .add(statusAnimationLabel)
                    .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(3, 3, 3))
        );

        jFrame1.setName("jFrame1"); // NOI18N

        org.jdesktop.layout.GroupLayout jFrame1Layout = new org.jdesktop.layout.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        );

        jFrame2.setName("jFrame2"); // NOI18N

        org.jdesktop.layout.GroupLayout jFrame2Layout = new org.jdesktop.layout.GroupLayout(jFrame2.getContentPane());
        jFrame2.getContentPane().setLayout(jFrame2Layout);
        jFrame2Layout.setHorizontalGroup(
            jFrame2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        jFrame2Layout.setVerticalGroup(
            jFrame2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        );

        jFrame3.setName("jFrame3"); // NOI18N

        org.jdesktop.layout.GroupLayout jFrame3Layout = new org.jdesktop.layout.GroupLayout(jFrame3.getContentPane());
        jFrame3.getContentPane().setLayout(jFrame3Layout);
        jFrame3Layout.setHorizontalGroup(
            jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        jFrame3Layout.setVerticalGroup(
            jFrame3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        app.hide(this);
        app.show(new ProductView(app, (String) titlelist.getSelectedValue()));
    }//GEN-LAST:event_jButton6ActionPerformed

    private void in3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_in3ActionPerformed

        Users.logout();



        if (Users.loggedin()) {
            out6.setVisible(false);
            out1.setVisible(false);
            password1.setVisible(false);
            out3.setVisible(false);
            password1.setVisible(false);
            in1.setVisible(true);
            in2.setVisible(true);
            in3.setVisible(true);
            in2.setText(Users.getCurrentUser().getUsername());
            in4.setVisible(true);
            wishlist.setVisible(true);

            out1.setText("Username");
            password1.setText("Password");
        } else {

            out1.setVisible(true);
            password1.setVisible(true);
            out3.setVisible(true);
            password1.setVisible(true);
            out6.setVisible(true);
            in1.setVisible(false);
            in2.setVisible(false);
            in3.setVisible(false);
            in4.setVisible(false);
            out1.setText("Username");
            password1.setText("Password");
            wishlist.setVisible(false);

        }

}//GEN-LAST:event_in3ActionPerformed

    private void out1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_out1FocusGained
        // TODO add your handling code here:
    }//GEN-LAST:event_out1FocusGained

    private void password1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_password1FocusGained
        // TODO add your handling code here:
    }//GEN-LAST:event_password1FocusGained

    private void loginbutton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginbutton1ActionPerformed

        if (Users.login(out1.getText(), password1.getText())) {


            if (Users.loggedin()) {
                out6.setVisible(false);
                out1.setVisible(false);
                password1.setVisible(false);
                out3.setVisible(false);
                password1.setVisible(false);
                in1.setVisible(true);
                in2.setVisible(true);
                in3.setVisible(true);
                in2.setText(Users.getCurrentUser().getUsername());
                in4.setVisible(true);
                wishlist.setVisible(true);

                out1.setText("Username");
                password1.setText("Password");
            } else {

                out1.setVisible(true);
                password1.setVisible(true);
                out3.setVisible(true);
                password1.setVisible(true);
                out6.setVisible(true);
                in1.setVisible(false);
                in2.setVisible(false);
                in3.setVisible(false);
                in4.setVisible(false);
                out1.setText("Username");
                password1.setText("Password");
                wishlist.setVisible(false);

                
            }
            // TODO add your handling code here:
    }//GEN-LAST:event_loginbutton1ActionPerformed
    }
    private void out3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_out3ActionPerformed
        app.hide(this);
        app.show(new Register(app));        // TODO add your handling code here:
    }//GEN-LAST:event_out3ActionPerformed

    private void wishlistActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wishlistActionPerformed
   app.hide(this);
        app.show(new WishListView(app));        // TODO add your handling code here:
    }//GEN-LAST:event_wishlistActionPerformed
    // TODO add your handling code here:
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton back1;
    private javax.swing.JButton browse1;
    private javax.swing.JButton home1;
    private javax.swing.JLabel in1;
    private javax.swing.JLabel in2;
    private javax.swing.JButton in3;
    private javax.swing.JPanel in4;
    private javax.swing.JButton jButton6;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JFrame jFrame2;
    private javax.swing.JFrame jFrame3;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton loginbutton1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JTextField out1;
    private javax.swing.JButton out3;
    private javax.swing.JPanel out6;
    private javax.swing.JTextField password1;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JList titlelist;
    private javax.swing.JButton wishlist;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
}
